var app = angular.module("app", [ 'base', 'baseDirective' ]);
app.controller('ctrl', [ '$scope', 'baseService', 'ArrayToolService', '$filter', function($scope, baseService, ArrayToolService, $filter) {
	var filter = $filter('filter');
	$scope.ArrayTool = ArrayToolService;

	$scope.init = function() {
		// 初始化数据
		$scope.expColumns = [];// 导出的字段

		var url = __ctx + "/bus/businessTable/getObject";
		var defer = baseService.postForm(url, {
			key : $.getParam("tableKey"),
			fill : true
		});
		$.getResultData(defer, function(data) {
			angular.forEach(data.columnsWithOutHidden, function(column) {
				var json = {
					key : column.key,
					comment : column.comment,
					exp : true
				};

				if (window.passData) {// 页面传来配置
					var columnKeys = window.passData.columnKeys.split(",");// 默认选中的字段
					var exist = false;
					angular.forEach(columnKeys, function(cn) {
						if (cn == column.key) {
							exist = true;
						}
					});
					if (!exist) {
						if (window.passData.fixed == "1") {// 只能操作固定的“选中的字段”
							return;
						}
						json.exp = false;
					}
				}

				$scope.expColumns.push(json);
			});
		}, null, true);
	};

} ]);
